package com.songVersion.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class YoutubeInfoCache
{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private String pattern;

	@Persistent
	private String videoId;
	@Persistent
	private String playerUrl;
	@Persistent
	private List<ThumbnailCache> thumbnails;

	@Persistent
	private Date insertDate;
	
	public YoutubeInfoCache()
	{
		super();
	}
	public YoutubeInfoCache(YoutubeInfoCache info)
	{
		super();
		if (info != null)
		{
			this.setKey(info.getKey());
			this.setInsertDate(info.getInsertDate());
			this.setPattern(info.getPattern());
			this.setPlayerUrl(info.getPlayerUrl());
			this.setVideoId(info.getVideoId());
			List<ThumbnailCache> thumbs = new ArrayList<ThumbnailCache>();
//			System.out.println(info.getThumbnails());
			for (ThumbnailCache t : info.getThumbnails())
			{
				ThumbnailCache t2 = new ThumbnailCache(t);
				/*
				t2.setHeight(t.getHeight());
				t2.setKey(t.getKey());
				t2.setUrl(t.getUrl());
				t2.setWidth(t.getWidth());
				*/
				thumbs.add(t2);
				//solo cargamos el primero
				break;
			}
			this.setThumbnails(thumbs);
		}
	}

	public Key getKey()
	{
		return key;
	}

	public void setKey(Key key)
	{
		this.key = key;
	}

	public String getPattern()
	{
		return pattern;
	}

	public void setPattern(String pattern)
	{
		this.pattern = pattern;
	}

	public String getVideoId()
	{
		return videoId;
	}

	public void setVideoId(String videoId)
	{
		this.videoId = videoId;
	}

	public String getPlayerUrl()
	{
		return playerUrl;
	}

	public void setPlayerUrl(String playerUrl)
	{
		this.playerUrl = playerUrl;
	}

	public List<ThumbnailCache> getThumbnails()
	{
		return thumbnails;
	}

	public void setThumbnails(List<ThumbnailCache> thumbnails)
	{
		this.thumbnails = thumbnails;
	}

	public Date getInsertDate()
	{
		return insertDate;
	}

	public void setInsertDate(Date insertDate)
	{
		this.insertDate = insertDate;
	}
}
